'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url client/template/kh/myGoods 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, pageIndex, pageSize } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始----------
    try {
      let { rows } = await vk.baseDao.selects({
        dbName: 'ai-user-goods',
        pageIndex, // 当前第几页
        pageSize, // 每页条数
        whereJson:{ // 条件
          "user_id": uid
        },
        foreignDB: [
          {
            dbName:"uni-id-users",
            localKey:"user_id",
            foreignKey:"_id",
            as:"userInfo",
            limit:1
          },
          {
            dbName:"ai-goods",
            localKey:"goods_id",
            foreignKey:"_id",
            as:"goodsInfo",
            limit:1
          }
        ]
      });
      res.data = rows
    } catch(err){
      res = { code: 500, msg: "查询错误" };
    }
    
    // 业务逻辑结束-----------------------------------------------------------
    return res;
	}
}
